<?php
/*------------------------------------------------------------------------
# com_ilike - XIPAT Like Article Component
# version: 1.0
# ------------------------------------------------------------------------
# author    Duong Tien Dung - www.xipat.com
# copyright Copyright (C) 2013 www.xipat.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.xipat.com
# Technical Support:  http://www.xipat.com/support.html
-------------------------------------------------------------------------*/
// no direct access

defined('_JEXEC') or die;

/**
 * ilike component helper.
 *
 * @package		Joomla.Administrator
 * @subpackage	com_ilike
 * @since		1.6
 */
class ilikeHelper
{
	/**
	 * Configure the Linkbar.
	 *
	 * @param	string	The name of the active view.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public static function addSubmenu($vName)
	{
		
			JSubMenuHelper::addEntry(
				JText::_('COM_XP_LIKE_SUBMENU_XPLIKES'),
				'index.php?option=com_ilike&view=xplikes',
				$vName == 'xplikes'
			);

		
	}

	/**
	 * Gets a list of the actions that can be performed.
	 *
	 * @param	int		The category ID.
	 *
	 * @return	JObject
	 * @since	1.6
	 */
	public static function getActions($categoryId = 0)
	{
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($categoryId)) {
			$assetName = 'com_ilike';
		} else {
			$assetName = 'com_ilike.category.'.(int) $categoryId;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
    
    /**
     * Testing state of the system bot
     *
     */
    public static function _testSystemBotState()
    {
        $db =& JFactory::getDBO();
        $botState = false;
        $db->setQuery( "SELECT * FROM #__extensions WHERE type='plugin' AND element='ilike'");
        $db->query();
        $plugin = $db->loadObject();
        if ($plugin != null && $plugin->enabled == "1") {
            $botState = $plugin->extension_id;
        }
        return $botState;
    }
    public static function getPluginid()
    {
        $db =& JFactory::getDBO();
        $db->setQuery( "SELECT * FROM #__extensions WHERE type='plugin' AND element='ilike'");
        $db->query();
        $plugin = $db->loadObject();
        return $plugin;
    }    
    
}
